import { makeAutoObservable } from 'mobx'
import type { IData } from './interface'

class Store {
    question: string = ''
    answer: string = ''
    isOver: boolean = false
    submitInfo: IData | Record<string, any> = {}
    formData: any = {}
    edit: boolean = false

    constructor() {
        makeAutoObservable(this)
    }
    /** 设置答案 */
    setAnswer = (value: string) => {
        this.answer = value
    }
    /** 设置问题 */
    setQues = (value: string, formData: any) => {
        this.formData = formData
        this.question = value
    }
    /** 切换是否结束 */
    toggleIsOver = (value?: boolean) => {
        this.isOver = typeof value === 'boolean' ? value : !this.isOver
    }
    /** 设置问题信息 */
    setSubmitInfo = (value: IData) => {
        this.submitInfo = value
    }
    /** 重新编辑 */
    setEdit = (val: boolean) => {
        this.edit = val
    }
}
export default new Store()
